/**
 * 
 */
package uniandes.dermatologia.training.activities;

import uniandes.dermatologia.R;
import uniandes.dermatologia.models.PhysicalExamination;
import uniandes.dermatologia.models.PhysicalExamination.Shape;
import uniandes.dermatologia.singleton.DermatologiaUniandesApp;
import uniandes.dermatologia.training.CaseLogic;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;

/**
 * @author Julio
 *
 */
public class ShapeCaseActivity extends Activity 
{
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_shape);

		getActionBar().setDisplayHomeAsUpEnabled(false);
		
		DermatologiaUniandesApp app = (DermatologiaUniandesApp)getApplication();
		
		CaseLogic caseLogic = app.getCurrentCaseLogic();
		
		PhysicalExamination examination = caseLogic.getExamination();
		
		Shape shape = examination.getShape();
		
		TextView lblShape = (TextView)findViewById(R.id.lblShapeSelection);
		lblShape.setText("Forma de lesion presentada");
		
		RadioButton radioAnnularShape = (RadioButton)findViewById(R.id.radioAnnularShape);
		radioAnnularShape.setEnabled(false);
		RadioButton radioCircinateShape = (RadioButton)findViewById(R.id.radioCircinateShape);
		radioCircinateShape.setEnabled(false);
		RadioButton radioDomeShape = (RadioButton)findViewById(R.id.radioDomeShape);
		radioDomeShape.setEnabled(false);
		RadioButton radioRaggedShape = (RadioButton)findViewById(R.id.radioRaggedShape);
		radioRaggedShape.setEnabled(false);
		RadioButton radioOvalShape = (RadioButton)findViewById(R.id.radioOvalShape);
		radioOvalShape.setEnabled(false);
		RadioButton radioPedunculatedShape = (RadioButton)findViewById(R.id.radioPedunculatedShape);
		radioPedunculatedShape.setEnabled(false);
		RadioButton radioRoundShape = (RadioButton)findViewById(R.id.radioRoundShape);
		radioRoundShape.setEnabled(false);
		RadioButton radioUmbilicatedShape = (RadioButton)findViewById(R.id.radioUmbilicatedShape);
		radioUmbilicatedShape.setEnabled(false);
		RadioButton radioOtherShape = (RadioButton)findViewById(R.id.radioOtherShape);
		radioOtherShape.setEnabled(false);
		
		switch (shape) {
		case annular:
			radioAnnularShape.setChecked(true);
			break;
		case circinate:
			radioCircinateShape.setChecked(true);
			break;
		case dome_shaped:
			radioDomeShape.setChecked(true);
			break;
		case ragged:
			radioRaggedShape.setChecked(true);
			break;
		case oval:
			radioOvalShape.setChecked(true);
			break;
		case pedunculated:
			radioPedunculatedShape.setChecked(true);
			break;
		case round:
			radioRoundShape.setChecked(true);
			break;
		case umbilicated:
			radioUmbilicatedShape.setChecked(true);
			break;
		case other:
			radioOtherShape.setChecked(true);
			break;
		default:
			break;
		}
		
		Button btnBack = (Button) findViewById(R.id.btnBackShape);
		Button btnNext = (Button) findViewById(R.id.btnNextShape);

		Typeface font = Typeface.createFromAsset(getAssets(),
				"fonts/Roboto-Light.ttf");

		btnBack.setTypeface(font);
		btnNext.setTypeface(font);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.shape, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			// This ID represents the Home or Up button. In the case of this
			// activity, the Up button is shown. Use NavUtils to allow users
			// to navigate up one level in the application structure. For
			// more details, see the Navigation pattern on Android Design:
			//
			// http://developer.android.com/design/patterns/navigation.html#up-vs-back
			//
			NavUtils.navigateUpFromSameTask(this);
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	public void onClickNext(View v) {

		Intent intent = new Intent(this, NumberCaseActivity.class);
		startActivity(intent);
	}

	public void onClickBack(View v) {
		finish();
	}
	
	/*
	 * (non-Javadoc)
	 * @see android.app.Activity#onPause()
	 */
	@Override
	protected void onPause() {
		super.onPause();
		DermatologiaUniandesApp app = (DermatologiaUniandesApp)getApplication();
		app.stopTimer();
	}
	
	/*
	 * (non-Javadoc)
	 * @see android.app.Activity#onResume()
	 */
	@Override
	protected void onResume() {
		super.onResume();
		DermatologiaUniandesApp app = (DermatologiaUniandesApp)getApplication();
		app.startTimer();
	}
}
